home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
janus11.zip
/
JANUS.DOC
< prev
next >
Wrap
Text File
|
1996-04-19
|
20KB
|
679 lines
████┐ ███████┐ ██████┐ ██┐ ██┐ ██┐ ███████┐
└██┌┘ ██┌──██│ ██┌─██│ ██│ ██│ ██│ ██┌────┘
██│ ███████│ ██│ ██│ ██│ ██│ ██│ ███████┐
██ ██│ ██┌──██│ ██│ ██│ ██│ ██│ ██│ └────██│
██████│ ██│ ██│ ██│ ██████│ ███████│ ███████│
└─────┘ └─┘ └─┘ └─┘ └─────┘ └──────┘ └──────┘
Borland C Programmer's Communications Library
(c)1994 Servile Software
2
INTRODUCTION:
~~~~~~~~~~~~~
Software for use with local computers receive their input from the user by way
of the keyboard functions included with the development language and display
output to the user through the video functions also supplied with the
development language. Remote computer access through the serial port requires
that user input comes from functions not supplied with the development
language, and the same is true of output functions which must send information
to the user by way of the serial port. Janus provides additional functions for
your Borland C development language which allow remote keyboard input, and
remote video display to occur.
To further assist with the writing of BBS doors Janus also includes an
automatic process for reading the caller information files created by many BBS
packages; DOOR.SYS and DOORINFO?.DEF. Janus defines global variables which
record caller information provided by the BBS package; The caller's name,
location, telephone numbers and so on. Janus also provides global variables
which record information about the connection; baud speed, data bits, the
terminal emulation in use and so on.
Janus takes care of monitoring the connection and terminates the program
automatically should the connection be lost, or the caller's connection time
exceeds that which is allowed (as defined by the host BBS setup).
SHAREWARE NOTICE:
~~~~~~~~~~~~~~~~~
Janus is supplied in small memory model only for shareware evaluation
purposes. The library is fully functional and differs from the registered
version only in displaying a shareware notice upon exit, and delaying two
seconds so that you and your callers can read the message.
The registered version includes small, medium, compact and large memory models
without the shareware notice and three second delay on leaving the door.
TUTORIAL:
~~~~~~~~~
There are a few basic principles which must be grasped before you can make use
of Janus. Firstly, Janus provides additional functions which enhance your
Borland C development language to allow you to accept input from a remote
operator through the serial port, and enable you to send output to the remote
caller. In order to do this the Janus functions require that the program is
running on an IBM PC or compatible computer and that a FOSSIL driver is
installed in memory. Program's written and making use of Janus's extra
functions will work fine locally without a loaded FOSSIL driver, but for
remote access it is essential.
Before your program calls any Janus functions the remote capabilities must be
initialised - the door opened - this is achieved with a call to the Janus
function j_open_door(). This function takes a single character string
parameter. This parameter specifies the full path and name of the BBS drop
file to be read by Janus. If you specify a null string - "" - Janus will
search the current DOS directory for a file called "DOOR.SYS" and if it fails
to find that "DORINFO?.DEF" where the ? is any character.
3
Before the Janus enganced program terminates back to the BBS or DOS, it must
de-initialise - close the door - and this is achieved by the Janus function
j_close_door(). It is recommended that you make use of the Borland C atexit()
function to ensure that the required functions are called when the program
terminates as Janus can terminate from within its own functions.
The process is simply:
1 open door
2 do program
3 close door
4 return
The following source code describes an extremely simple door program. The
program displays a welcome message to the caller on both the caller's (remote)
screen and on the sysop's (local) screen. Notice the inclusion of the header
file "JANUS.H".
/*
A very simple door
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "janus.h" /* Prototypes and global variable definitions */
main(int argc, char **argv)
{
strcpy(program_name,"SIMPLE DOOR"); /* Initialise program name */
if (argc > 1)
j_open_door(argv[1]); /* Initialise with drop file */
else
j_open_door(""); /* Initialise */
atexit(j_close_door); /*
Ensure the door is
de-initialised on exit
*/
j_printf("\r\nHello %s",username); /* Print to terminals */
return;
}
NAMING CONVENTIONS:
~~~~~~~~~~~~~~~~~~~
Janus functions are named as similarly to the Borland C local equivalents as
possible, but are prefixed "j_" thus j_printf() is a remote variation on
printf().
Libraries are prefixed JANUS followed by a letter indicating the memory model;
S,M,C or L. The small memory model library is named "JANUSS.LIB"
4
INPUT FUNCTIONS:
~~~~~~~~~~~~~~~~
Just as C provides several functions for receiving input from the local
keyboard, so Janus provides several functions for receiving input from the
remote caller. All Janus functions check for the presence of a carrier and
keyboard time out and will terminate the program should the caller hang-up,
not press a key within the allotted time or if the caller's on-line time is
exceeded.
j_inkey()
Waits for a key press from either the local or remote terminal and returns an
unsigned char of the key code without echoing the character to the screen.
Equivalent to the C getch() function.
j_iskey()
Checks for a waiting key press from either the local or remote terminal and
returns non-zero if a key is available. The key code may be read with
j_inkey(). Unlike j_inkey() this function does not wait for a key to be
pressed, and so may be used within a loop to check if input is arriving from
either the caller or the sysop.
j_input(length, password, caps, hot, type);
j_input() is a general-purpose input function. It returns a pointer to a
string, and is used with strcpy().
The parameters are all single byte. The first parameter, 'length', specifies
the maximum number of characters which may be entered into the string. If the
'password' parameter is non-zero, dots will echo the input, otherwise the
input characters will be echoed to both the local and remote terminals.
if the 'caps' parameter is non-zero, input will be forced to CAPITALS.
If the 'hot' parameter is non-zero, the function doesn't wait for a carriage-
return to be pressed, it returns when 'length' bytes have been entered.
The final parameter, 'type', specifies the behaviour of j_input() as
illustrated in the following table:
TYPE ALLOWABLE INPUT CHARACTERS
1 Any printable character
2 Letters (A-Z) plus space only
3 Digits (0-9) only
4 Letters (A-Z) plus digits (0-9) and space only
5 Y and N only
6 Name input. Only allows letters (A-Z), space and hyphen.
5
First character must be letter
Maximum of one space
First letter of each word capitalised
7 Neat input. Only allows letters (A-Z), digits (0-9) and
space.
Fi